import pymysql

class MysqlHelper(object):
    def __init__(self):
        self.con = pymysql.connect(host='127.0.0.1',port=3306,user='root',password='123456',database='py14',charset='utf8mb4')
        self.cursor = self.con.cursor()
    def execute_insert_sql(self,insert_sql,data):
        self.cursor.execute(insert_sql,data)
        self.con.commit()

    def __del__(self):
        self.cursor.close()
        self.con.close()
if __name__ == '__main__':
    helper = MysqlHelper()
    insert_sql = 'INSERT INTO weibo_test(create_at,content) VALUES (%s,%s)'